Ext.define('PHT.CheckUrlCfgWindow', {
    extend: 'Ext.window.Window',

    title: 'Check URL Configuration',
    closable: true,
    closeAction: 'hide',
    width: 600,
    minWidth: 350,
    height: 350,
    //bodyStyle: 'padding: 5px;',
    layout: {
        type: 'border'
    },

    initComponent: function() {
        var me = this;
        
        Ext.applyIf(me, {
            items: [
                {
                    xtype: 'chkurlavailgrid',
                },
                {
                    xtype: 'chkurlcheckinglgrid',
                },
                {
                    xtype: 'panel',
                    layout: {
                        align: 'center',
                        pack: 'center',
                        type: 'vbox'
                    },
                    //title: 'My Panel',
                    region: 'center',
                    items: [
                        {
                            xtype: 'button',
                            text: 'Import >>',
                            handler: function(){
                            	var grid = Ext.getCmp('available-grid');
                            	var selection = grid.getView().getSelectionModel().getSelection()[0];
                                if (selection) {
                                	
                                	//add checking
                                    var store_checking = Ext.data.StoreManager.lookup('checkingURL-store');
                                    var data = {};
                                    data.name = selection.data.name;
                                    store_checking.insert(0,data);
                                    
                                	//delete available
                                	var store_available = Ext.data.StoreManager.lookup('available-store');
                                    store_available.remove(selection);
                                    
                                    
                                    
                                }else{
                                	Ext.MessageBox.alert("error","Import operation fail!");
                                }
                                
                            }
                        },
                        {
                            xtype: 'button',
                            text: 'Remove <<',
                            handler: function(){
                            	var grid = Ext.getCmp('checking-grid');
                            	var selection = grid.getView().getSelectionModel().getSelection()[0];
                                if (selection) {
                                	//delete checking
                                	var store_checking = Ext.data.StoreManager.lookup('checkingURL-store');
                                	store_checking.remove(selection);
                                    
                                    //add available
                                    var store_available = Ext.data.StoreManager.lookup('available-store');
                                    var data = {};
                                    data.name = selection.data.name;
                                    store_available.insert(0,data);
                                    
                                }else{
                                	Ext.MessageBox.alert("error","Remove operation fail!");
                                }
                                
                            }
                        }
                    ]
                }
            ]
        });

        me.callParent(arguments);
    }
});